<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="../cwjy/css/app.css" rel="stylesheet">
    <style>
        html::-webkit-scrollbar {
            display: none
        }
    </style>
</head>
<script src="../cwjy/js/app.js"></script>
<script src="../cwjy/js/jquery.min.js"></script>
<body >
<div class="card" >
    <div class="card-header">
        <div>
            <div style="float:left;text-align: center;width: 100%">
                <span style="font-weight: bold;font-size: 30px;text-shadow: 1px 1px 2px #000000;">宠物寄养登记</span>
            </div>
        </div>
    </div>
    <div class="" style="width: 100%">
        <div class="card" style="width:50%;margin-left: 25%">
            <div class="card-header">
                <h5 class="card-title"  style="font-weight: bold;font-size: 20px;text-shadow: 1px 1px 2px #000000;">寄养</h5>
                <h6 class="card-subtitle text-muted"  style="font-weight: bold;font-size: 20px;text-shadow: 1px 1px 2px #000000;">寄养详细</h6>
            </div>
            <div class="card-body">
                <form  style="font-weight: bold;font-size: 15px;text-shadow: 2px 2px 2px #cccccc;">
                    <div class="mb-3 row">
                        <label class="col-form-label col-sm-2 text-sm-right">主人姓名</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="master_name" placeholder="主人姓名">
                        </div>
                    </div>
                    <div class="mb-3 row">
                        <label class="col-form-label col-sm-2 text-sm-right">电话</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="phone"   placeholder="电话">
                        </div>
                    </div>
                    <div class="mb-3 row">
                        <label class="col-form-label col-sm-2 text-sm-right">详细地址</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" id="address_home"  placeholder="详细地址" rows="3"></input>
                        </div>
                    </div>
                    <div class="mb-3 row">
                        <label class="col-form-label col-sm-2 text-sm-right">寄养开始日期</label>
                        <div class="col-sm-10">
                            <input type="date" id="foster_care_start_time"  class="form-control" placeholder="寄养开始日期" rows="3"></input>
                        </div>
                    </div>

                    <div class="mb-3 row">
                        <label class="col-form-label col-sm-2 text-sm-right">预计结束日期</label>
                        <div class="col-sm-10">
                            <input  type="date" class="form-control" id="foster_care_end_time"  placeholder="预计结束日期" rows="3"></input>
                        </div>
                    </div>

                    <fieldset class="mb-3" id="pet_type" >
                        <div class="row">
                            <label class="col-form-label col-sm-2 text-sm-right pt-sm-0">宠物种类</label>
                            <div class="col-sm-10">
                             <!--   <label class="form-check">
                                    <input name="radio-3" type="radio" id = '1' class="form-check-input" checked>
                                    <span class="form-check-label">纯种狗狗</span>
                                </label>
                                <label class="form-check">
                                    <input name="radio-3" type="radio" id = '2' class="form-check-input">
                                    <span class="form-check-label">纯种猫</span>
                                </label>-->
                                <label class="form-check">
                                    <input name="radio-3" type="radio" id = '3' class="form-check-input" >
                                    <span class="form-check-label">普通狗狗</span>
                                </label>
                                <label class="form-check">
                                    <input name="radio-3" type="radio" id = '4' class="form-check-input" >
                                    <span class="form-check-label">普通猫</span>
                                </label>
                                <label class="form-check">
                                    <input name="radio-3" type="radio" id = '5' class="form-check-input" >
                                    <span class="form-check-label">其它</span>
                                </label>
                            </div>
                        </div>
                    </fieldset>

                    <div class="mb-3 row">
                        <label class="col-form-label col-sm-2 text-sm-right">其他品种</label>
                        <div class="col-sm-10">
                            <input  type="text" id="other_type"  class="form-control" placeholder="其他品种" rows="3"></input>
                        </div>
                    </div>
                    <fieldset class="mb-3" id="is_rabies_vaccine" >
                        <div class="row">
                            <label class="col-form-label col-sm-2 text-sm-right pt-sm-0">是否接种狂犬疫苗</label>
                            <div class="col-sm-10">
                                <label class="form-check">
                                    <input name="radio-5" type="radio" id = "1" class="form-check-input" checked>
                                    <span class="form-check-label">是</span>
                                </label>
                                <label class="form-check">
                                    <input name="radio-5" type="radio" id = "0" class="form-check-input">
                                    <span class="form-check-label">否</span>
                                </label>
                            </div>
                        </div>
                    </fieldset>

                    <fieldset class="mb-3" id="is_pregnancy_or_estrus" >
                        <div class="row">
                            <label class="col-form-label col-sm-2 text-sm-right pt-sm-0">是否发情或怀孕</label>
                            <div class="col-sm-10">
                                <label class="form-check">
                                    <input name="radio-4" type="radio" id = '1' class="form-check-input" checked>
                                    <span class="form-check-label">是</span>
                                </label>
                                <label class="form-check">
                                    <input name="radio-4" type="radio" id = '0' class="form-check-input">
                                    <span class="form-check-label">否</span>
                                </label>
                            </div>
                        </div>
                    </fieldset>


                    <div class="mb-3 row">
                        <label class="col-form-label col-sm-2 text-sm-right">寄养备注</label>
                        <div class="col-sm-10">
                            <textarea class="form-control" id="remarks"  placeholder="寄养备注" rows="3"></textarea>
                        </div>
                    </div>

                    <div class="mb-3 row">
                        <label class="col-form-label col-sm-2 text-sm-right">物品清单</label>
                        <div class="col-sm-10">
                            <textarea class="form-control" id="checklist"  placeholder="物品清单" rows="3"></textarea>
                        </div>
                    </div>

                    <div class="mb-3 row">
                        <label class="col-form-label col-sm-2 text-sm-right">预约上门时间</label>
                        <div class="col-sm-10">
                            <input type="datetime-local" id="reservation_time"  class="form-control" placeholder="Textarea" rows="3"></input>
                        </div>
                    </div>

                    <div class="mb-3 row">
                        <div class="col-sm-10 ml-sm-auto">
                            <button type="button" class="btn btn-primary" onclick="addPetBoarding()">提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!--模态框-->

<!--<div class="modal fade" id="defaultModalPrimary" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header" id = "modelHead">

            </div>
            <div class="modal-body m-3">
                <div class="card-body" id="modelDiv">

                </div>
            </div>
            <div class="modal-footer" id="modelAction">

            </div>
        </div>
    </div>
</div>-->
<script type="text/javascript" src="../cwjy/js/ajaxAll.js"></script>
<script type="text/javascript">
   function addPetBoarding(){

       /**主人名称*/
       let master_name = $('#master_name').val();
       /**手机号码*/
       let phone = $('#phone').val();
       /**家庭住址*/
       let address_home = $('#address_home').val();
       /**寄养开始时间*/
       let foster_care_start_time = $('#foster_care_start_time').val();
       /**寄养结束时间*/
       let foster_care_end_time = $('#foster_care_end_time').val();
       /**获取宠物类型*/
       let pet_type_radio = $('input:radio[name="radio-3"]:checked');
       let pet_type = pet_type_radio[0].id;
       let other_type = $('#other_type').val();
       /**是否注射狂犬疫苗*/
       let is_rabies_vaccine_radio = $('input:radio[name="radio-5"]:checked');
       let is_rabies_vaccine =is_rabies_vaccine_radio[0].id;
       /**是否发情*/
       let is_pregnancy_or_estrus_radio = $('input:radio[name="radio-4"]:checked');
       let is_pregnancy_or_estrus =is_pregnancy_or_estrus_radio[0].id;
       /**备注*/
       let remarks = $('#remarks').val();
       /**服务*/
       let checklist = $('#checklist').val();
       /**预约时间*/
       let reservation_time = $('#reservation_time').val().replaceAll("T"," ");

       let url = "http://localhost:8888/cwjy/PetBoarding/insert";

       let json  = {master_name:master_name, phone:phone, address_home:address_home
           , foster_care_start_time:foster_care_start_time, foster_care_end_time:foster_care_end_time, pet_type:pet_type
           , other_type:other_type, is_rabies_vaccine:is_rabies_vaccine, is_pregnancy_or_estrus:is_pregnancy_or_estrus
           , remarks:remarks, checklist:checklist, reservation_time:reservation_time};
       let success = "寄养成功";
       let error = "寄养失败";
       if(master_name === "" || phone === "" || address_home === ""  || foster_care_start_time === ""  || foster_care_end_time === ""
           || pet_type === ""  || is_rabies_vaccine === "" || is_pregnancy_or_estrus === ""  ){
           alert('有资料未输入,请输入！')
           return;
       }
       if(!isPhoneNo(phone)){
           alert('手机号码输入错误，请重新输入')
           return;
       }
       ajaxUnifiedCallUpdateAndAdd(url,json,success,error)
   }

</script>

</body>
</html>